from flask import Flask, render_template, request, jsonify
from chatbot_graph import ChatBotGraph

app = Flask(__name__)
handler = ChatBotGraph()

@app.route('/')
def home():
    return render_template('index.html')

@app.route('/ask', methods=['POST'])
def ask():
    question = request.form.get('question')
    if question:
        answer = handler.chat_main(question)
        return jsonify({'answer': answer})
    return jsonify({'answer': '抱歉，我没有理解您的问题'})

if __name__ == '__main__':
    app.run(debug=True) 